home *** CD-ROM | disk | FTP | other *** search
- #ifndef __STD_IOMANIP__
- #define __STD_IOMANIP__
- #pragma option push -b -a4 -Vx- -Ve- -w-inl -w-aus -w-sig
-
- /***************************************************************************
- *
- * iomanip - Declarations for the Standard Library iomanip classes
- *
- * $Id: iomanip,v 1.22 1996/08/28 01:28:48 smithey Exp $
- *
- ***************************************************************************
- *
- * (c) Copyright 1994, 1995 Rogue Wave Software, Inc.
- * ALL RIGHTS RESERVED *
- * The software and information contained herein are proprietary to, and
- * comprise valuable trade secrets of, Rogue Wave Software, Inc., which
- * intends to preserve as trade secrets such software and information.
- * This software is furnished pursuant to a written license agreement and
- * may be used, copied, transmitted, and stored only in accordance with
- * the terms of such license and with the inclusion of the above copyright
- * notice. This software and information or any other copies thereof may
- * not be provided or otherwise made available to any other person.
- *
- * Notwithstanding any other lease or license that may pertain to, or
- * accompany the delivery of, this computer software and information, the
- * rights of the Government regarding its use, reproduction and disclosure
- * are as set forth in Section 52.227-19 of the FARS Computer
- * Software-Restricted Rights clause.
- *
- * Use, duplication, or disclosure by the Government is subject to
- * restrictions as set forth in subparagraph (c)(1)(ii) of the Rights in
- * Technical Data and Computer Software clause at DFARS 252.227-7013.
- * Contractor/Manufacturer is Rogue Wave Software, Inc.,
- * P.O. Box 2328, Corvallis, Oregon 97339.
- *
- * This computer software and information is distributed with "restricted
- * rights." Use, duplication or disclosure is subject to restrictions as
- * set forth in NASA FAR SUP 18-52.227-79 (April 1985) "Commercial
- * Computer Software-Restricted Rights (April 1985)." If the Clause at
- * 18-52.227-74 "Rights in Data General" is specified in the contract,
- * then the "Alternate III" clause applies.
- *
- **************************************************************************/
-
- #include <stdcomp.h>
- #include <iosfwd>
- #include <iostream>
-
- #ifndef _RWSTD_NO_NAMESPACE
- namespace std {
- #endif
-
-
- /*
- * class smanip
- *
- */
-
- template<class T>
- class smanip {
-
- public:
-
- smanip(ios_base& (*pf)(ios_base&, T), T manarg)
- : pf_(pf)
- , manarg_(manarg)
- { ; }
-
-
- ios_base& (*pf_)(ios_base&, T);
- T manarg_;
-
- protected:
-
- private:
-
- };
-
- /*
- * class smanip_fill
- *
- */
-
- template<class T, class traits>
- class smanip_fill {
-
- public:
-
- smanip_fill(basic_ios< T, traits >& (*pf)(basic_ios< T, traits >&, T), T manarg)
- : pf_(pf)
- , manarg_(manarg)
- { ; }
-
-
- basic_ios< T, traits >& (*pf_)(basic_ios< T, traits >&, T);
- T manarg_;
-
- protected:
-
- private:
-
- };
-
-
- /*
- * global manipulators
- */
-
-
- inline ios_base& rsios(ios_base& str, ios_base::fmtflags mask)
- {
- str.setf((ios_base::fmtflags)0, mask);
-
- return str;
- }
-
-
- inline ios_base& sios(ios_base& str, ios_base::fmtflags mask)
- {
- str.setf(mask);
-
- return str;
- }
-
-
- inline ios_base& sbase(ios_base& str, int base)
- {
- str.setf(base == 8 ? ios_base::oct :
- base == 10 ? ios_base::dec :
- base == 16 ? ios_base::hex :
- ios_base::fmtflags(0), ios_base::basefield);
-
- return str;
- }
-
- template < class charT, class traits >
- inline basic_ios< charT, traits >& sfill( basic_ios< charT, traits >& str, charT c)
- {
- str.fill(c);
-
- return str;
- }
-
- inline ios_base& sprec(ios_base& str, int n)
- {
- str.precision(n);
-
- return str;
- }
-
- inline ios_base& swidth(ios_base& str, int n)
- {
- str.width(n);
-
- return str;
- }
-
-
- inline smanip<ios_base::fmtflags> resetiosflags(ios_base::fmtflags mask )
- { return smanip<ios_base::fmtflags>(rsios, mask); }
-
- inline smanip<ios_base::fmtflags> setiosflags(ios_base::fmtflags mask )
- { return smanip<ios_base::fmtflags>(sios, mask); }
-
- inline smanip<int> setbase(int base)
- { return smanip<int>(sbase, base); }
-
- template < class charT >
- inline smanip_fill<charT, char_traits<charT> > setfill( charT c)
- { return smanip_fill<charT, char_traits<charT> >(
- (basic_ios< charT, char_traits<charT> >& (*)(basic_ios< charT,
- char_traits<charT> >&, charT))sfill, c);
- }
-
- inline smanip<int> setprecision(int n)
- { return smanip<int>(sprec, n); }
-
- inline smanip<int> setw(int n)
- { return smanip<int>(swidth, n); }
-
- template<class charT, class traits, class T>
- inline basic_istream<charT, traits>& operator>>(basic_istream<charT, traits>& is, const smanip<T>& a)
- {
- #ifndef _RWSTD_NO_EXCEPTIONS
- try {
- (*a.pf_)(is, a.manarg_);
- }
- catch(...) {
- is.setstate(ios_base::failbit);
- }
- #else
- (*a.pf_)(is, a.manarg_);
- #endif
-
- return is;
- }
-
- template<class charT, class traits, class T>
- inline basic_ostream<charT, traits>& operator<<(basic_ostream<charT, traits>& os, const smanip<T>& a)
- {
- #ifndef _RWSTD_NO_EXCEPTIONS
- try {
- (*a.pf_)(os, a.manarg_);
- }
- catch(...) {
- os.setstate(ios_base::failbit);
- }
- #else
- (*a.pf_)(os, a.manarg_);
- #endif
-
- return os;
- }
-
- template<class T, class traits>
- inline basic_istream<T, traits>& operator>>(basic_istream<T, traits>& is, const smanip_fill<T, traits>& a)
- {
- #ifndef _RWSTD_NO_EXCEPTIONS
- try {
- (*a.pf_)(is, a.manarg_);
- }
- catch(...) {
- is.setstate(ios_base::failbit);
- }
- #else
- (*a.pf_)(is, a.manarg_);
- #endif
-
- return is;
- }
-
- template<class T, class traits>
- inline basic_ostream<T, traits>& operator<<(basic_ostream<T, traits>& os, const smanip_fill<T, traits>& a)
- {
- #ifndef _RWSTD_NO_EXCEPTIONS
- try {
- (*a.pf_)(os, a.manarg_);
- }
- catch(...) {
- os.setstate(ios_base ::failbit);
- }
- #else
- (*a.pf_)(os, a.manarg_);
- #endif
-
- return os;
- }
-
- #ifndef _RWSTD_NO_NAMESPACE
- }
- #endif
-
- #pragma option pop
- #endif /* __IOMANIP__ */
-